/*
 * Created on 2005-3-17
 */
package com.hd123.rumba.user;

import com.hd123.rumba.cartridge.FVRumbaSystem;
import com.hd123.rumba.exception.StringTooLongException;
import com.hd123.rumba.runtime.BaseEntity;

/**
 * @author caili
 */
public class Department extends BaseEntity implements IDepartment {

  /** 构件包前缀 */
  public static final String FUNCV_PREFIX = FVRumbaSystem.FUNCV_PREFIX;
  
  private String code;
  private String name;
  private String remark;

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#getCode()
   */
  public String getCode() {
    return code;
  }

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#setCode(java.lang.String)
   */
  public void setCode(String code) throws StringTooLongException {
    if (code != null) {
      code = code.trim().toUpperCase();
      code = truncate(code, LENGTH_CODE, "code", CAPTION_CODE);
    }
    this.code = code;
  }

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#getName()
   */
  public String getName() {
    return name;
  }

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#setName(java.lang.String)
   */
  public void setName(String name) throws StringTooLongException {
    if (name != null) {
      name = truncate(name, LENGTH_NAME, "name", CAPTION_NAME);
    }
    this.name = name;
  }

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#getRemark()
   */
  public String getRemark() {
    return remark;
  }

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#setRemark(java.lang.String)
   */
  public void setRemark(String remark) throws StringTooLongException {
    if (remark != null) {
      remark = truncate(remark, LENGTH_REMARK, "remark", CAPTION_REMARK);
    }
    this.remark = remark;
  }

  /* (non-Javadoc)
   * @see com.hd123.rumba.user.IDepartment#getCodeName()
   */
  public String getCodeName() {
    return getCode() + "[" + getName() + "]";
  }

  public String getNameCode() {
    return getName() + "[" + getCode() + "]";
  }
}
